package team.knowers.qzh.qzhgrame.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


import team.knowers.qzh.qzhgrame.common.convention.result.Result;
import team.knowers.qzh.qzhgrame.common.convention.result.Results;
import team.knowers.qzh.qzhgrame.dto.req.*;
import team.knowers.qzh.qzhgrame.dto.resp.AllCourseRespDTO;
import team.knowers.qzh.qzhgrame.dto.resp.CourseMessageRespDTO;
import team.knowers.qzh.qzhgrame.dto.resp.CoursePageRespDTO;
import team.knowers.qzh.qzhgrame.service.CourseGrameService;

import java.util.List;


@RestController
@RequiredArgsConstructor
public class CourseGrameController {
    private final CourseGrameService coursegrameService;
    /**
     * 用户添加课程
     */
    @PostMapping("/api/qzh-server/admin/v1/course/add")
    public Result<Integer> addCourse(@RequestBody AddCourseReqDTO req) {
        return Results.success(coursegrameService.addCourse(req));
    }
    /**
     * 删除课程
     *
     */
    @PutMapping("/api/qzh-server/admin/v1/course/delete/{id}")
    public Result<Integer> deleteCourse(@PathVariable("id") Long id)
    {
        return Results.success(coursegrameService.deleteCourse(id));
    }
    /**
     * 修改课程
     */
    @PutMapping("/api/qzh-server/admin/v1/course/update")
    public Result<Integer> updateCourse(@RequestBody UpdateCourseReqDTO req)
    {
        return Results.success(coursegrameService.updateCourse(req));
    }
    /**
     *课程审查通过
     *
     */
    @PutMapping("/api/qzh-server/admin/v1/course/examine/yes")
    public Result<String> examineCourse(@RequestBody ExamineCourseReqDTO req){
        return Results.success(coursegrameService.examineCourse(req));
    }
    /**
     *课程审查未通过
     *
     */
    @PutMapping("/api/qzh-server/admin/v1/course/examine/not")
    public Result<String> notExamineCourse(@RequestBody ExamineCourseReqDTO req){
        return Results.success(coursegrameService.notExamineCourse(req));
    }
    /**
     * 分页查询创作课程
     */
    @PostMapping("/api/qzh-server/admin/v1/course/show")
    public Result<IPage<CoursePageRespDTO>> pageCourse(@RequestBody PageCourseReqDTO req){
        return Results.success(coursegrameService.pageCourse(req));
    }
    /**
     * 展示单个课程
     *
     */
    @GetMapping("/api/qzh-server/admin/v1/course/show/{id}")
    public Result<CourseMessageRespDTO>  showCourse(@PathVariable("id") Long id)
    {
        return Results.success(coursegrameService.showCourse(id));
    }
    /**
     * 发布课程
     */
    @PutMapping("/api/qzh-server/admin/v1/course/release")
    public Result<Integer> rsleaseCourse(@RequestBody ReleaseCourseReqDTO req)
    {
        return Results.success(coursegrameService.rsleaseCourse(req));
    }
    /**
     * 展示某专业所有课程
     */
    @GetMapping("/api/qzh-server/admin/v1/subject/show/{id}")
    public Result<List<AllCourseRespDTO>>  showMajorCourse(@PathVariable("id") Long id){
        return Results.success(coursegrameService.showMajorCourse(id));
    }
    /**
     * 取消发布课程
     */
    @PutMapping("/api/qzh-server/admin/v1/course/cancelrelease")
    public Result<Integer> cancelRsleaseCourse(@RequestParam("id") Long id)
    {
        return Results.success(coursegrameService.cancelRsleaseCourse(id));
    }
}
